package cn.edu.zut.hhr.service.impl;

import cn.edu.zut.hhr.entity.ArticleTag;
import cn.edu.zut.hhr.mapper.ArticleTagMapper;
import cn.edu.zut.hhr.service.ArticleTagService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 文章_标签关联表,用来指定某个文章的标签 服务实现类
 * </p>
 *
 * @author HHR
 * @since 2021-08-26
 */
@Service
public class ArticleTagServiceImpl extends ServiceImpl<ArticleTagMapper, ArticleTag> implements ArticleTagService {

    @Resource
    ArticleTagMapper articleTagMapper;

    @Override
    public void insertMany(List<ArticleTag> articleTags) {
        articleTagMapper.insertMany(articleTags);
    }

    @Override
    public List<ArticleTag> getArticleTagsByTid(Integer tid) {
        LambdaQueryWrapper<ArticleTag> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ArticleTag::getTid,tid);
        return articleTagMapper.selectList(queryWrapper);
    }
}
